package com.acwing.partition4;

import java.io.*;
import java.util.LinkedList;
import java.util.Queue;

/**
 * @author `RKC`
 * @date 2022/1/20 16:30
 */
public class AC361观光奶牛 {

    private static final int N = 1010, M = 5010;
    private static int[] head = new int[N], element = new int[M], next = new int[M];
    private static int[] w1 = new int[N], w2 = new int[M], cnt = new int[N];
    private static boolean[] inQueue = new boolean[N];

    private static double[] dist = new double[N];

    private static int n = 0, m = 0, idx = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] s = reader.readLine().split("\\s+");
        n = Integer.parseInt(s[0]);
        m = Integer.parseInt(s[1]);
        for (int i = 0; i < N; i++) head[i] = -1;
        for (int i = 0; i < n; i++) w1[i + 1] = Integer.parseInt(reader.readLine());
        for (int i = 0; i < m; i++) {
            s = reader.readLine().split("\\s+");
            int u = Integer.parseInt(s[0]), v = Integer.parseInt(s[1]), w = Integer.parseInt(s[2]);
            createEdge(u, v, w);
        }
        writer.write(String.format("%.2f\n", binarySearch()));
        writer.flush();
    }

    private static double binarySearch() {
        double left = 0, right = 1010;
        while (right - left > 1e-4) {
            double mid = (left + right) / 2;
            if (spfa(mid)) left = mid;
            else right = mid;
        }
        return left;
    }

    private static boolean spfa(double mid) {
        Queue<Integer> queue = new LinkedList<>();
        for (int i = 1; i <= n; i++) {
            queue.add(i);
            inQueue[i] = true;
            dist[i] = 0;
            cnt[i] = 0;
        }
        while (!queue.isEmpty()) {
            int u = queue.poll();
            inQueue[u] = false;
            for (int i = head[u]; i != -1; i = next[i]) {
                int v = element[i];
                double w = w2[i] * mid - w1[u];
                if (dist[v] > dist[u] + w) {
                    dist[v] = dist[u] + w;
                    cnt[v] = cnt[u] + 1;
                    if (cnt[v] >= n) return true;
                    if (inQueue[v]) continue;
                    queue.add(v);
                    inQueue[v] = true;
                }
            }
        }
        return false;
    }

    private static void createEdge(int u, int v, int w) {
        element[idx] = v;
        next[idx] = head[u];
        head[u] = idx;
        w2[idx++] = w;
    }
}
